/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 13-6-7
 * Time: 上午11:26
 * To change this template use File | Settings | File Templates.
 */
/**
 * Demonstrates a range of Button options the framework offers out of the box
 */
Ext.define('cloud.view.message.Message', {
    extend: 'Ext.navigation.View',
    xtype: 'message',
    requires: ['Ext.List', 'Ext.TitleBar', 'Ext.field.Select', 'Ext.field.Search'],
    config: {
        defaultBackButtonText: '返回',
        items: [
            {
                xtype: 'container',
                layout: 'hbox',
                title: '客户留言',
                items: [
                    {
                        xtype: 'toolbar',
                        ui: 'dark',
                        docked: 'top',
                        items: [

                            {
                                xtype: 'textfield',
                                id: 'message_search',
                                name: 'message_search',
                                style: 'center',
                                placeHolder: '请输入留言内容',
                                listeners: {
                                    focus: function () {
                                        var Store = Ext.getStore('MessageDistrictFindStore');
                                        var value = this.getValue();
                                        Store.clearFilter();
                                        if (value != "") {
                                            Store.filter('messages', value, true);
                                        }
                                        Store.load({params: {cadid: localStorage.getItem('cadid')}});
                                        }

                                }
                            }

                        ]
                    },
                    {
                        xtype: 'list',
                        id: 'messageSelect',
                        flex: 1,
                        store: 'MessageDistrictFindStore',
                        emptyText: '还未添加客户留言',
                        pressedCls: false,
                        selectedCls: false,
                        cls: 'x-list2',
                        onItemDisclosure: true,
                        itemTpl: [
                            '<div class="listName">{messages}</div>' +
                                '<div class="listConten">' +
                                '<span>是否显示：{isview}</span> ' +
                                ' <span>管理员回复: {remessage }</span>' +
                                ' <span> 留言时间: {lasttime }</span> ' +
                                '</div>'
                        ].join(''),
                        listeners: {
                            painted: function () {
                                var message = Ext.getStore('MessageDistrictFindStore');
                                message.load(
                                    {params: {cadid: localStorage.getItem('cadid')}}
                                );
                                message.getProxy().setExtraParam('cadid', localStorage.getItem('cadid'))
                            }
                        },
                        plugins: [
                            {
                                xclass: 'Ext.plugin.PullRefresh',
                                pullRefreshText: '下拉可以更新',
                                releaseRefreshText: '松开开始更新',
                                style: 'top:12px',
                                loadingText: '正在刷新……',
                                refreshFn: function (loaded, arguments) {
                                    //loaded.getList().getStore().getProxy().setExtraParam('cadid', localStorage.getItem('cadid')); //设置proxy参数
                                    loaded.getList().getStore().loadPage(1, {
                                        callback: function (record, operation, success) {
                                            Ext.Viewport.unmask();
                                        }, scope: this });
                                }
                            },
                            {
                                xclass: 'Ext.plugin.ListPaging',
                                loadMoreText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">点击加载更多。。。。</h2>',
                                noMoreRecordsText: '<h2 style="text-align: center; padding-top: 20px; padding-bottom: 20px;">没有更多条记录了</h2>',
                                autoPaging: false //设置为TRUE将自动触发
                            }
                        ]
                    },
                    {
                        xtype: 'toolbar',
                        id: 'message_toolbar',
                        docked: 'bottom',
                        layout: {
                            type: 'hbox',
                            pack: 'center'
                        }
//                        items: [
//                            {
//                                xtype: 'button',
//                                id: 'message_btn_add',
//                                iconMask: true,
//                                iconCls: 'add'
//                            }
//                        ]
                    }
                ]
            }
        ]
    }
});
